home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / sgwnd10 / frmtrayi.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-09-16  |  5.1 KB  |  164 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
  3. Begin VB.Form frmTrayIcon 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "SG Window - TrayIcon Sample"
  6.    ClientHeight    =   3285
  7.    ClientLeft      =   2640
  8.    ClientTop       =   2805
  9.    ClientWidth     =   4980
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   3285
  14.    ScaleWidth      =   4980
  15.    ShowInTaskbar   =   0   'False
  16.    Begin VB.PictureBox pctIcon 
  17.       AutoRedraw      =   -1  'True
  18.       AutoSize        =   -1  'True
  19.       BorderStyle     =   0  'None
  20.       Height          =   435
  21.       Left            =   240
  22.       ScaleHeight     =   435
  23.       ScaleWidth      =   495
  24.       TabIndex        =   3
  25.       Top             =   780
  26.       Width           =   495
  27.    End
  28.    Begin VB.CommandButton cmdSetIcon 
  29.       Caption         =   "Change Icon"
  30.       Height          =   435
  31.       Left            =   3420
  32.       TabIndex        =   2
  33.       Top             =   840
  34.       Width           =   1395
  35.    End
  36.    Begin MSComDlg.CommonDialog CommonDialog1 
  37.       Left            =   4320
  38.       Top             =   1500
  39.       _ExtentX        =   847
  40.       _ExtentY        =   847
  41.       _Version        =   327681
  42.    End
  43.    Begin VB.CommandButton cmdTip 
  44.       Caption         =   "Change Tooltip"
  45.       Height          =   435
  46.       Left            =   3420
  47.       TabIndex        =   1
  48.       Top             =   240
  49.       Width           =   1395
  50.    End
  51.    Begin VB.TextBox txtTooltip 
  52.       BeginProperty Font 
  53.          Name            =   "MS Sans Serif"
  54.          Size            =   9.75
  55.          Charset         =   238
  56.          Weight          =   400
  57.          Underline       =   0   'False
  58.          Italic          =   0   'False
  59.          Strikethrough   =   0   'False
  60.       EndProperty
  61.       Height          =   375
  62.       Left            =   240
  63.       TabIndex        =   0
  64.       Text            =   "Text1"
  65.       Top             =   240
  66.       Width           =   3075
  67.    End
  68.    Begin VB.Label lblStatus 
  69.       Height          =   315
  70.       Left            =   120
  71.       TabIndex        =   4
  72.       Top             =   2880
  73.       Width           =   4695
  74.    End
  75.    Begin VB.Menu mnuPopup 
  76.       Caption         =   "Popup"
  77.       Visible         =   0   'False
  78.       Begin VB.Menu mnuShow 
  79.          Caption         =   "Show Form"
  80.       End
  81.       Begin VB.Menu mnuHide 
  82.          Caption         =   "Hide Form"
  83.       End
  84.       Begin VB.Menu mnuExit 
  85.          Caption         =   "E&xit"
  86.       End
  87.    End
  88. Attribute VB_Name = "frmTrayIcon"
  89. Attribute VB_GlobalNameSpace = False
  90. Attribute VB_Creatable = False
  91. Attribute VB_PredeclaredId = True
  92. Attribute VB_Exposed = False
  93. '--------------------------------------------------------------------------
  94. ' This file is part of the SG Window
  95. ' This sample shows how to use SG Window to put form into the
  96. ' system try. Note that all code needed to add and manage
  97. ' tray icon API is encapsulated in the TrayIcon class.
  98. ' Copyright 
  99.  1998 Stinga
  100. ' All rights reserved
  101. ' You have a right to use and modify this code. However,
  102. ' Stinga is not responsible for what you may do with this
  103. ' or any modification of this code.
  104. '--------------------------------------------------------------------------
  105. Option Explicit
  106. ' Declare TrayIcon object and connect to it's events
  107. Private WithEvents mTray As SGTrayIcon.TrayIcon
  108. Attribute mTray.VB_VarHelpID = -1
  109. Private Sub cmdSetIcon_Click()
  110.    CommonDialog1.Filter = "Icon Files (*.ico)|*.ico||"
  111.    CommonDialog1.ShowOpen
  112.    If CommonDialog1.filename <> "" Then
  113.       Set pctIcon.Picture = LoadPicture(CommonDialog1.filename)
  114.       Set mTray.Icon = pctIcon.Picture
  115.    End If
  116. End Sub
  117. Private Sub cmdTip_Click()
  118.    mTray.Tip = txtTooltip.Text
  119.    txtTooltip.Text = mTray.Tip
  120. End Sub
  121. Private Sub Command1_Click()
  122.    Set mTray.Icon = Me.Icon
  123. End Sub
  124. Private Sub Form_Load()
  125.    ' Create TrayIcon object and connect to tray icon events
  126.    Set mTray = New SGTrayIcon.TrayIcon
  127.    ' Initialize tray icon object
  128.    ' Set owner form and menu that will be used as a
  129.    ' popup menu when user clicks with right mouse button
  130.    Set mTray.Form = Me
  131.    Set mTray.PopupMenu = mnuPopup
  132.    ' Set tray icon and tooltip text
  133.    Set mTray.Icon = Me.Icon
  134.    mTray.Tip = "SG Window TrayIcon Sample"
  135.    ' Add icon to the system tray
  136.    mTray.Add
  137.    ' Update form controls
  138.    txtTooltip.Text = mTray.Tip
  139.    Set pctIcon.Picture = mTray.Icon
  140. End Sub
  141. Private Sub Form_Terminate()
  142.    ' Remove icon from the system tray
  143.    mTray.Remove
  144. End Sub
  145. Private Sub mnuExit_Click()
  146.    Unload Me
  147. End Sub
  148. Private Sub mnuHide_Click()
  149.    Me.Hide
  150. End Sub
  151. Private Sub mnuShow_Click()
  152.    Me.Show
  153. End Sub
  154. Private Sub mTray_DblClick(ByVal x As Single, ByVal y As Single)
  155.    If Me.Visible Then
  156.       Me.Hide
  157.    Else
  158.       Me.Show
  159.    End If
  160. End Sub
  161. Private Sub mTray_MouseMove(ByVal x As Single, ByVal y As Single)
  162.    lblStatus.Caption = "MouseMove at " & CStr(x) & ", " & CStr(y)
  163. End Sub
  164.